Skip to content

gh-146152: Fix memory leak in _json encoder error paths#146164

Open
okiemute04 wants to merge 15 commits intopython:mainfrom
okiemute04:fix-json-encoder-leak
Open

gh-146152: Fix memory leak in _json encoder error paths#146164
okiemute04 wants to merge 15 commits intopython:mainfrom
okiemute04:fix-json-encoder-leak

Conversation

@okiemute04
Copy link
Contributor

@okiemute04 okiemute04 commented Mar 19, 2026

Fixes #146152

Add PyDict_DelItem calls to remove objects from the markers dict
on all error paths in encoder_listencode_obj. Previously, objects
were only removed on the success path, causing memory leaks when:

  • default() raises an exception
  • RecursionError occurs
  • Nested encoding fails

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_json: stale markers entries on error paths in encoder_listencode_obj

3 participants